#include<bits/stdc++.h>
using namespace std;
#define int long long

int a[5000005], delta[5000005], preSum[5000005];

signed main() {
	int n, p;
	cin >> n >> p;
	for (int i = 1; i <= n; i++)
		cin >> a[i], delta[i] = a[i] - a[i - 1];
	while (p--) {
		int x, y, z;
		cin >> x >> y >> z;
		delta[x] += z;
		delta[y + 1] -= z;
	}
	for (int i = 1; i <= n; i++) {
		preSum[i] = preSum[i - 1] + delta[i];
	}
	cout << *min_element(preSum + 1, preSum + n + 1);
	return 0;
}
